Skip to content

Weather app eval submission#210

Open
colormethanh wants to merge 3 commits intoprojectshft:masterfrom
colormethanh:master
Open

Weather app eval submission#210
colormethanh wants to merge 3 commits intoprojectshft:masterfrom
colormethanh:master

Conversation

@colormethanh
Copy link

No description provided.

const data = await fetchData(url);

// If location is not found
if(data.length === 0) return -1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its better thrown an error and catch it in later.

};

const getCurrentWeatherData = async function (lon, lat, unit="imperial") {
const returnData = {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing semi colon


const getCurrentWeatherData = async function (lon, lat, unit="imperial") {
const returnData = {}
const url = `https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lon}&units=${unit}&appid=${APIKEY}`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

const url = `https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lon}&units=${unit}&appid=${APIKEY}`
const data = await fetchData(url);
returnData.name = data.name;
returnData.temp = data.main.temp;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if by any reason, main is not being returned, this will crash. Safer to use ?

Suggested change
returnData.temp = data.main.temp;
returnData.temp = data.main?.temp;

const data = await fetchData(url);
returnData.name = data.name;
returnData.temp = data.main.temp;
const {description, icon} = data.weather[0];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const {description, icon} = data.weather[0];
const { description, icon } = data.weather[0];

check your spacing

const getCurrentWeatherData = async function (lon, lat, unit="imperial") {
const returnData = {}
const url = `https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lon}&units=${unit}&appid=${APIKEY}`
const data = await fetchData(url);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data and return data are very generic names, you want to use something more explicit.

returnData.temp = data.main.temp;
const {description, icon} = data.weather[0];
const output = {...returnData, weather: description, iconCode: icon};
return output;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as you wont call your inputs - 'input', don't call it output. Can be:
currentWeatherData same as your function.
makes sense?

Comment on lines +58 to +60
dateArr.push(itm);
dateSeparatedArr.push(dateArr);
dateArr = [];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is confusing and prone to bugs. Will be hard to maintain.
A lot is being mutated here.

Comment on lines +119 to +120
console.log("setDefaultBtn clicked");
console.log(weatherComponent.name);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove console logs

console.log(weatherComponent.name);
localStorage.setItem("WEATHERPROJECT", JSON.stringify({"name": weatherComponent.name}));
$("#default-city-text").text(`Default city: ${weatherComponent.name}`);
toggleModal("Success!", "New Default location has been set!");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can set incorrect city names as default. Should validate!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, I think you need to be able to set as default ONLY if you have that city already populated with data, otherwise that button stays disabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants